package com.xbell.app.sys.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.xbell.app.sys.common.GridDataSet;
import com.xbell.app.sys.common.PageInfo;
import com.xbell.app.sys.dao.AbstractBaseDao;


@Service
public class HdglService  implements HdglServiceI {

	@Autowired
	AbstractBaseDao daoI;
	
	@Override
	public GridDataSet<List<Map<String, Object>>> allLogs(PageInfo pg, String title) {
		String sql = "select id,ip,title,opid,optime from syslog where 1=1 <#if title?has_content> and title like :title</#if>";
		pg.setDefaultOrder("optime desc");
		Map<String,Object> params = new HashMap<String,Object>();
		this.daoI.addLikeParamIfNotBlank(params,"title", title);
		return this.daoI.fastPageSql(this.daoI.formatSql(sql, params, this.getClass(), "allHds"), pg, params);
	}

	@Transactional
	@Override
	public int delLog(String id) {
		String sql = "delete from syslog where id=:id";
		return this.daoI.execUpdateSql(sql, "id",id);
	}
	
	
	
}
